package com.tencent.qf.common.zhiyan;

import com.tencent.zhiyan.log.sdk.ZhiyanLogTcpClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Slf4j
@Component
public class ZhiyanLogTcpClientBean extends ZhiyanLogTcpClient {
    public ZhiyanLogTcpClientBean(ZhiyanConfig logProperties) {
        super(logProperties.getTopic(), logProperties.isCompress(), logProperties.getServers());
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            log.info("智研日志客户端关闭...");
            try {
                this.close();
            } catch (IOException e) {
                log.error("关闭智研日志TCP客户端错误:{}", e);
            }
        }));
    }
}
